<template>
  <!-- 添加或修改盘点计划对话框 -->
  <el-dialog :title="title" v-if="open" v-model="open" width="600px" append-to-body>
    <div v-loading="loading">
      <el-form ref="form" :model="form" :rules="rules" label-width="90px" :inline="false">
        <el-form-item label="审核状态:" prop="auditStatus">
          <el-radio-group v-model="form.auditStatus">
            <el-radio label="1">通过</el-radio>
            <!-- <el-radio label="0">不通过</el-radio> -->
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核批注:" prop="auditRemark">
          <el-input type="textarea" style="width: 600px" :rows="4" v-model="form.auditRemark"></el-input>
        </el-form-item>
      </el-form>
    </div>

    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitAudit" :loading="loading">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
import modelMixin from '@/mixins/modelMixin'
import followOrder from '@/api/goods/followOrder'
import useUserStore from '@/store/modules/user';
const userStore = useUserStore();
export default {
  name: 'addForm',
  mixins: [modelMixin],
  data() {
    return {
      open: false,
      title: '审核',
      funcObj: followOrder,
      form: {},
      supplierOptions: [],//客户
      rules: {
        auditStatus: [
          {
            required: true,
            message: '请选择审核状态',
            trigger: 'blur'
          }
        ],
      },
      active: 1,
      data: [],
      loading: false,
    };
  },

  methods: {
    edit(row) {
      this.open = true;
      this.title = '审核'
      this.form = {
      }
      this.dataSource = []
      this.getDicts('quote_status');
      this.getDetail(row)
    },

    cancel() {
      this.open = false;
    },
    selectHandle(row) {
      return 1;
    },
    handleAdd() {
      this.$refs.selectMaterialForm.show();
    },
    remoteMethod(query, listKey, key) {
      const optionKey = listKey + 'Options';
      if (query !== '') {

        this[optionKey] = this[listKey + 'List'].filter(item => {
          return item[key].toLowerCase()
            .indexOf(query.toLowerCase()) > -1;
        });
      } else {
        this[optionKey] = this[listKey + 'List'];
      }

    },
    submitAudit(close = true) {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.loading = true
          this.form.auditUserId = userStore.userId;
          this.funcObj.audit(this.form).then(res => {
            this.loading = false
            if (res.code == 200) {
              this.$modal.msgSuccess("审核成功");
              if (close) {
                this.open = false;
              }
              this.$emit('ok');
            } else {
              this.$modal.msgError(res.msg)
            }
          }).catch(err => {
            this.loading = false
            console.log('err :>> ', err);
          })
        }
      });
    }
  }
}
</script>

<style lang="scss" scoped></style>